package com.satan.fmmall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.satan.fmmall.entity.IndexImg;
import com.satan.fmmall.mapper.IndexImgMapper;
import com.satan.fmmall.service.IndexImgService;
import com.satan.fmmall.vo.ResCode;
import com.satan.fmmall.vo.ResultVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName IndexImgServiceImpl
 * @Description TODO
 * @date 2022/4/3 22:44
 * @Version 1.0
 */
@Service
public class IndexImgServiceImpl implements IndexImgService {
    @Resource
    private IndexImgMapper indexImgMapper;

    @Override
    public ResultVo listIndexImgs() {
        LambdaQueryWrapper<IndexImg> queryWrapper=new LambdaQueryWrapper();
        queryWrapper.eq(IndexImg::getStatus,1);
        queryWrapper.orderByAsc(IndexImg::getSeq);
        List<IndexImg> indexImgs = indexImgMapper.selectList(queryWrapper);
        if (indexImgs.size()==0){
            return ResultVo.fail(ResCode.NO_RESULT);
        }else {
            return ResultVo.success(indexImgs);
        }
    }
}
